package site.jlopen.components.entity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class GraphNodeAttr {
	// Xx
	private String prop;
	// Xx
	private String name;
	// Xx
	private String code;
	// Xx
	private String desc;
	// string integer float 
	private String type;
	// optional
	//private String optional;
	// required
	private boolean required = false;
	private List<Map<String, Object>> requiredMaps = new ArrayList<Map<String, Object>>();
	// 
	private String defVal;
	// 
	private List<String> possible = new ArrayList<String>();
	// 
	private String max;
	// 
	private String min;
	
	public void beupload() {
		if(this.required && requiredMaps.size() == 0) {
			Map<String, Object> requiredMap = new HashMap<String, Object>();
			requiredMap.put("required", true);
			requiredMap.put("message", "不能为空");
			if(this.possible.size() > 0) {
				requiredMap.put("trigger", "change");
			}else {
				requiredMap.put("trigger", "blur");
			}
			requiredMaps.add(requiredMap);
		}
		if(StringUtils.isBlank(this.prop) && StringUtils.isNotBlank(this.defVal)) {
			this.prop = this.defVal;
		}
	}
	
	public GraphNodeAttr() {
		super();
	}
}